package com.kingschan.jeasytag.tag.base;

import java.io.IOException;

import javax.servlet.jsp.JspException;

import com.kingschan.jeasytag.core.annotations.tag.*;
import com.kingschan.jeasytag.core.parse.TagParseFactory;
import com.kingschan.jeasytag.tag.RootTag;
/**
 * page
 * @author kingschan
 *date:2013-3-19
 */
@TagMetaData(CssClass = "easyui-pagination", tag = "div"
		)
public class PaginationTag extends RootTag {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@NumberField
	private String total;
	@NumberField
	private String pageSize;
	@NumberField
	private String pageNumber;
	@IntArrayField
	private String pageList;
	@BooleanField
	private String loading;
	@StringField(appendFlag="")
	private String buttons;
	@BooleanField
	private String showPageList;
	@BooleanField
	private String showRefresh;
	@StringField
	private String beforePageText;
	@StringField
	private String afterPageText;
	@StringField
	private String displayMsg;
	@EventField(args = "pageNumber, pageSize", description = "Fires when user select a new page. callback function contains two parameter:pageNumber: the new page number pageSize: the new page size")
	private String onSelectPage;
	@EventField(args = "pageNumber,pageSize", description = "Fires before the refresh button is clicked, return false to cancel the refresh action")
	private String onBeforeRefresh;
	@EventField(args = "pageNumber,pageSize", description = "Fires after refresh.")
	private String onRefresh;
	@EventField(args = "pageSize", description = "Fires when user change the page size.")
	private String onChangePageSize;


	@Override
	public int doStartTag() throws JspException {
		
		try {
			this.pageContext.getOut().write(TagParseFactory.executeParse(this,pageContext));
		} catch (Exception e) {		
			e.printStackTrace();
		}
		return super.doStartTag();
	}
	
	@Override
	public int doEndTag() throws JspException {
		try {
			this.pageContext.getOut().write("</div>");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return super.doEndTag();		
	}
	
	
	public String getTotal() {
		return total;
	}

	public void setTotal(String total) {
		this.total = total;
	}

	public String getPageSize() {
		return pageSize;
	}

	public void setPageSize(String pageSize) {
		this.pageSize = pageSize;
	}

	public String getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(String pageNumber) {
		this.pageNumber = pageNumber;
	}

	public String getPageList() {
		return pageList;
	}

	public void setPageList(String pageList) {
		this.pageList = pageList;
	}

	public String getLoading() {
		return loading;
	}

	public void setLoading(String loading) {
		this.loading = loading;
	}

	public String getButtons() {
		return buttons;
	}

	public void setButtons(String buttons) {
		this.buttons = buttons;
	}

	public String getShowPageList() {
		return showPageList;
	}

	public void setShowPageList(String showPageList) {
		this.showPageList = showPageList;
	}

	public String getShowRefresh() {
		return showRefresh;
	}

	public void setShowRefresh(String showRefresh) {
		this.showRefresh = showRefresh;
	}

	public String getBeforePageText() {
		return beforePageText;
	}

	public void setBeforePageText(String beforePageText) {
		this.beforePageText = beforePageText;
	}

	public String getAfterPageText() {
		return afterPageText;
	}

	public void setAfterPageText(String afterPageText) {
		this.afterPageText = afterPageText;
	}

	public String getDisplayMsg() {
		return displayMsg;
	}

	public void setDisplayMsg(String displayMsg) {
		this.displayMsg = displayMsg;
	}

	public String getOnSelectPage() {
		return onSelectPage;
	}

	public void setOnSelectPage(String onSelectPage) {
		this.onSelectPage = onSelectPage;
	}

	public String getOnBeforeRefresh() {
		return onBeforeRefresh;
	}

	public void setOnBeforeRefresh(String onBeforeRefresh) {
		this.onBeforeRefresh = onBeforeRefresh;
	}

	public String getOnRefresh() {
		return onRefresh;
	}

	public void setOnRefresh(String onRefresh) {
		this.onRefresh = onRefresh;
	}

	public String getOnChangePageSize() {
		return onChangePageSize;
	}

	public void setOnChangePageSize(String onChangePageSize) {
		this.onChangePageSize = onChangePageSize;
	}

}
